﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ProcessModule_Maintenance.aspx.vb" Inherits="MyWorkflow.ProcessModule_Maintenance" %>
<html>
<head>
    <title>审批流程</title>
    <link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
    <script language="javascript" src="/_common/scripts/global.js"></script>
    <script language="javascript" src="/myWorkflow/workflow_Mini.js"></script>
    <script language="javascript" src="/_controls/upfile/UpFile.js"></script>
    <script language="javascript" src="/myWorkflow/js/wf_cancelBackSpace.js"></script>
    <style>
        TABLE.layout
        {
	        table-layout:		fixed;
	        width:				100%;
	        height:				100%;
        }
        DIV.area
        {
	        padding:			5px;
	        overflow-y:			auto;
	        width:				100%;
	        height:				100%;
        }
        DIV.txt
        {
            height:				19px;
            line-height:        20px;
	        background-color:	transparent;
	        width:				100%;
	        border:				1px solid #cccccc;
	        text-decoration:    underline;
	        color:              blue;	        	        	        
        }
        INPUT
        {
	        font-size:			9pt;
	        font-family:		宋体,Tahoma, Verdana, Arial;
	        width:				100%;
	        height:				19px;
	        border:				1px solid #cccccc;
	        background-color:	transparent;
        }
        textarea
        {
            font-size:			9pt;
	        font-family:		宋体,Tahoma, Verdana, Arial;
	        background-color:	transparent;
	    }
	    IMG.btn
	    {
	        cursor:				hand;	    
	    }
    </style>
    
    <script language="javascript">
    function $id(id) { return document.getElementById(id);}
    function viewProcess()
    {
        var sProcessGUID = $id("ProcessModuleGUID").value;
		if (sProcessGUID != "" && sProcessGUID != undefined)
		{
			var sPath = "/MyWorkflow/WF_ProcessDefined_Form.aspx?mode=3&amp;&amp;oid=" + sProcessGUID + getXMLPath($id("ProcessType").value);
			openMyFullWin(sPath);
		}
    }
    function selectProcess()
    {
        var sURL,sParam, iX, iY;        
        sURL = "/Myworkflow/interface/PUB/SelectProcessModule.aspx?";
        sParam = "AllowAdd=" + ($id("__Action").value=="Edit"?"true":"false");
        sParam += "&BusinessTypeName=" + escape($id("__BusinessTypeName").value);
        sParam += "&ExtendFormUrl=" + escape($id("__ExtendFormUrl").value);
               
        iX = 600;
        iY = 500;
        
        var pm = openMyDlg("选择流程模板", sURL, sParam , window, iX, iY);
        
        if (pm == null) return;
        
        if (pm.ProcessGUID == "")
        {
            //返回空值
            $id("ProcessModuleGUID").value = "";
            $id("ProcessName").innerHTML = "";
            $id("txtDescription").value = "";
            $id("ProcessType").value = "";
            $id("sdk").sdkName = "";
            $id("sdk").sdkUrl = "";
            $id("sdk").innerText = "";
            $id("ifrChart").src = "WF_ProcessDefined_View.aspx?processMode=0&mode=2&processGUID=";
        }
        else
        {
            openWaiting();
            pmInfo = GetProcessModuleInfo(pm.ProcessGUID);
            if (pmInfo == null)
            {
                closeWaiting();    
                return;
            }
            //需要请求新的流程模板
            $id("ProcessModuleGUID").value = pm.ProcessGUID;            
            $id("ProcessName").innerHTML = pm.ProcessName;
            $id("txtDescription").value = pmInfo.Description;
            $id("ProcessType").value = pmInfo.ProcessType;
            $id("sdk").sdkName = pmInfo.SDKName;
            $id("sdk").sdkUrl = pmInfo.SDKURL;
            $id("sdk").innerText = pmInfo.SDKName;
            
            var url = "WF_ProcessDefined_View.aspx?processMode=0&mode=2&processGUID="+pm.ProcessGUID ;
            $id("ifrChart").src = url;
            
            closeWaiting();
        }
    }
    function createProcess(type)
    {
        var url = $id("__ExtendFormUrl")?$id("__ExtendFormUrl").value:"";
			    
        var sPath = "/MyWorkflow/WF_ProcessDefined_Form.aspx?mode=1";			    
        sPath += "&processKindGUID=601a167c-ef97-440e-99eb-24d76ab682af";
        sPath += "&documentType=" + type + "&ExtendFormUrl=" + escape(url);
        
        sPath += getXMLPath(type);

	    var win = openMyFullWin(sPath,"NewProcess");
	    win.focus();
    }    
    function modifyProcess()
    {
        var sProcessGUID = $id("ProcessModuleGUID").value;
		if (sProcessGUID != "" && sProcessGUID != undefined)
		{
			var sPath = "/MyWorkflow/WF_ProcessDefined_Form.aspx?mode=2&amp;oid=" + sProcessGUID;			
			
			sPath += getXMLPath($id("ProcessType").value);
			
			openMyFullWin(sPath);
		}
		else
		    alert("您没有设置流程模板！");
    }
    function getXMLPath(type)
    {   
		if (type == 2)
            return "&xml=/MyWorkflow/WF_ProcessDefined_Form_Extend.xml";
        else if (type == 1)
            return "&xml=/MyWorkflow/WF_ProcessDefined_Form_Doc.xml";
        else 
            return "&xml=/MyWorkflow/WF_ProcessDefined_Form.xml";
    }
    function afterWorkflow(ProcessGUID)
    {
        openWaiting();
        pmInfo = GetProcessModuleInfo(ProcessGUID);
        if (pmInfo == null)
        {
            closeWaiting();    
            return;
        }
        $id("ProcessName").innerHTML = pmInfo.ProcessName;
        $id("txtDescription").value = pmInfo.Description;
        $id("sdk").sdkName = pmInfo.SDKName;
        $id("sdk").sdkUrl = pmInfo.SDKURL;
        $id("sdk").innerText = pmInfo.SDKName;
        
        var url = "WF_ProcessDefined_View.aspx?processMode=0&mode=2&processGUID="+ProcessGUID ;
        $id("ifrChart").src = url;
        
        closeWaiting();
    }
    function getProcessModuleGUID()
    {
        return $id("ProcessModuleGUID").value;
    }
    function GetProcessModuleInfo(ProcessGUID)
    {
        var pm = GetDataFromXMLHTTP("/MyWorkflow/WF_XMLHTTP.aspx","GETPROCESSMODULEINFO",ProcessGUID,"","");

        if (pm != -1) 
            //return eval(pm.replace(/\r\n/g,"'+char(10)+char(13)+'"));
            return eval(pm.replace(/\r\n/g,"\\r\\n"));
        return null; 
    }
    function GetGUID()
    {
        var rtn = GetDataFromXMLHTTP("/MyWorkflow/WF_XMLHTTP.aspx","GetGUID","","","");

        if (rtn != -1) 
            return rtn;
        else
            return false;
    }
    function downFile()
    {
        sdkName = $id("sdk").sdkName;
        sdkUrl = $id("sdk").sdkUrl;        
        __DownUpFile_FZ(sdkName,sdkUrl,"_blank");
    }
    window.onload= function()
    {
        document.body.oncontextmenu = function(){return false}; 
        if ($id("__Action").value == "Edit")
        {
            $id("tdModify").style.display="";
            $id("tdSelect").style.display="";
        }
        else if ($id("__Action").value == "Select")
            $id("tdSelect").style.display="";
    }
    </script>
</head>
<body style="height:100%">
    <form id="form1" runat="server">
    <input id="__isallowopenfile" type="hidden" value="true" />
    <input id="__Action" type="hidden" value='<% = Request.QueryString("Action")%>' />
    <input id="__ExtendFormUrl" type="hidden" value='<% = Request.QueryString("ExtendFormUrl")%>' />    
    <input id="__BusinessTypeName" type="hidden" value='<% = Request.QueryString("BusinessTypeName")%>' />
    </form>
    <div class="area" style="background-color:White;">
    <table class="layout" cellpadding="2" cellspacing="0" border="0">
        <colgroup>
            <col width="80px" />
            <col />
        </colgroup>
        <tr height="24px">
            <td style="padding-left:10px;">审批流程</td>
            <td>
                <!--<input readOnly id="txtProcessName" value='<%=PMInfo.ProcessName %>'/>-->
                <table cellpadding="0" cellspacing="0" width="100%" style="table-layout:fixed;">
                    <tr>
                    <td nowrap>
                        <div class="txt"><span onclick="viewProcess();" style="cursor:hand;" id="ProcessName"><%=PMInfo.ProcessName %></span></div>
                        <input type="hidden" id="ProcessModuleGUID" value='<%=PMInfo.ProcessModuleGUID %>'>
                        <input type="hidden" id="ProcessType" value='<%=PMInfo.ProcessType %>'>
                    </td>
                    <td width="25" style="text-align: right;display:none" id="tdSelect">
                        <img class="btn" src="/_imgs/btn_off_lookup.gif" alt="选择流程模板" onclick="selectProcess();">
                    </td>
                    <td width="25" style="text-align: right;display:none" id="tdModify">
                        <img class="btn" src="/myWorkflow/images/editPM.gif" alt="编辑流程模板" onclick="modifyProcess();">
                    </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr height="64px">
            <td valign="top" style="padding-left:10px;">概要描述</td>
            <td><textarea readonly cols="4" id="txtDescription" style="height:60px;"><%=PMInfo.Description %></textarea></td>
        </tr>
        <tr height="24px">
            <td style="padding-left:10px;">流程指引</td>
            <td><span id="sdk" sdkName='<%=PMInfo.SDKName%>' sdkUrl='<%=PMInfo.SDKURL%>' onclick="downFile();" style="text-decoration:underline;color:Blue; cursor:hand"><%=PMInfo.SDKName%></span></td>
        </tr>
                
        <tr>
            <td colspan="2" valign="top" style="padding:2px;">
                <div style="border:1px solid #7b9ebd">
                    <table cellspacing="0" cellpadding="0" class="layout">
                        <tr>
                            <td valign="top">
                                <iframe id="ifrChart" src="WF_ProcessDefined_View.aspx?processMode=0&mode=3&processGUID=<%=PMInfo.ProcessModuleGUID %>" width='100%' height='100%' frameborder='0' scrolling='no'></iframe>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </table>
    </div>
    
    <script language="javascript"> 
    var iLeft = (document.body.clientWidth-200)/2;
    var iTop = (document.body.clientHeight-47)/2;
    document.writeln("<div id='__divRuning' style='POSITION: absolute; Z-INDEX: 108; Left:"+iLeft.toString()+"px; top:"+iTop.toString() + "px; width:223px; height:47px; BACKGROUND-COLOR: white; border:#9E9E9B 1px solid; font:bold 14px; color:#FF5A00; text-align:center; padding-top:16px; DISPLAY:none;'>处理中，请稍候...</div>");
    </script>

</body>
</html>
